<?php
App::uses('AppModel', 'Model');
/**
 * Anime Model
 *
 * @property Season $Season
 * @property Genre $Genre
 */
class Anime extends AppModel {


    public $actsAs = array(
        'Upload.Upload' => array(
            'photo' => array(
                'fields' => array(
                    'dir' => 'photo_dir'
                ),
                'thumbnailSizes' => array(
                    'xvga' => '1024x768',
                    'vga' => '300x200',
                    'thumb' => '80x80'
                ),
                'thumbnailMethod'	=> 'php'
            )
        )
    );

    /**
     * Validation rules
     *
     * @var array
     */
    public $validate = array(
        'name' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Infome o nome do anime.',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
/*        'genre'=>array(
            'notempty'=>array(
                'rule'=>array('notempty'),
                'message'=>'Informe o genero do anime.',
                'required'=>true,
//                'allowEmpty'=>,
            ),
        ),*/
        'photo' => array(
            'notempty'=>array(
                'rule' => array('extension',array('jpeg','jpg','png','gif')),
                'required' => false,
                'allowEmpty' =>false,
                'message' => 'Arquivo invalido.',
                'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'status' => array(
            'boolean' => array(
                'rule' => array('boolean'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
    );

    //The Associations below have been created with all possible keys, those that are not needed can be removed

    /**
     * hasMany associations
     *
     * @var array
     */
    public $hasMany = array(
        'Season' => array(
            'className' => 'Season',
            'foreignKey' => 'anime_id',
            'dependent' => true,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );


    /**
     * hasAndBelongsToMany associations
     *
     * @var array
     */
    public $hasAndBelongsToMany = array(
        'Genre' => array(
            'className' => 'Genre',
            'joinTable' => 'animes_genres',
            'foreignKey' => 'anime_id',
            'associationForeignKey' => 'genre_id',
            'unique' => 'keepExisting',
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'finderQuery' => '',
            'deleteQuery' => '',
            'insertQuery' => ''
        )
    );

}
